<?php 
	include_once 'dataservice.php';
	include_once 'thuvienham.php';

	class ngayhoc_db 
	{
		public function Them($MaThoiGianHoc, $NgayHoc)
		{
			$sql = "INSERT INTO `tbl_ngayhoc`(`MaThoiGianHoc`, `NgayHoc`)
					VALUES ('$MaThoiGianHoc', '$NgayHoc')";

			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}

		public function Xoa($MaThoiGianHoc)
		{
			$sql = "DELETE FROM `tbl_ngayhoc` WHERE `MaThoiGianHoc` = '$MaThoiGianHoc'";

			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}

		public function CapNhat($MaThoiGianHoc, $NgayHoc)
		{
			$sql = "UPDATE `tbl_ngayhoc`
					SET `NgayHoc` = '$NgayHoc'
					WHERE `MaThoiGianHoc` = '$MaThoiGianHoc'";

			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}

		public function LayDanhSach($MaThoiGianHoc, $NgayHoc)
		{
			$sql = "SELECT * FROM `tbl_ngayhoc` WHERE 1  ";
			if($MaThoiGianHoc != "")
				$sql .= " AND `MaThoiGianHoc` = '$MaThoiGianHoc' ";

			if($NgayHoc != -1)
				$sql .= " AND `NgayHoc` = '$NgayHoc' ";

			$service = new dataservice();
			return $service->ExecuteQuery($sql);
		}

	}

